"""
@Author  : 康帅
@Time    : 2021/7/1 13:42
@Function: enumerate函数
"""


def enumerate_index():
    """
    enumerate 可以取值 可以取下标
    :return:
    """
    data_list = ['a', 'b', 'c']
    for _, i in enumerate(data_list):
        print(_, i)


def enumerate_index_initial_value():
    """
    enumerate 设置初始值
    设置默认从1开始算下表值
    :return:
    """
    data_list = ['a', 'b', 'c']
    for _, i in enumerate(data_list, 1):
        print(_, i)


def enumerate_index_list():
    """
    创建包含索引的元组列表
    :return:
    """
    my_list = ['apple', 'banana', 'grapes', 'pear']
    counter_list = list(enumerate(my_list, 1))
    print(counter_list)


if __name__ == '__main__':
    enumerate_index()
    enumerate_index_initial_value()
    enumerate_index_list()
